package ru.tulupov.collectionsbenchmark.tester;

import java.util.Collection;
import java.util.Collections;

import org.apache.log4j.Logger;

public abstract class Tester<T> {
	private static final Logger LOGGER = Logger.getLogger(Tester.class);
	private Collection<T> collection;

	public Tester(Collection<T> collection) {
		this.collection = collection;
	}

	public void init(T[] elements) {
		Collections.addAll(collection, elements);
		LOGGER.info(String.format("Initialization of collection."));
	}

	public void sequentialAccess() {
		int count = 0;

		for (T t : collection) {
			if (t != null) {
				count++;
			}
		}

		LOGGER.info(String.format("Sequential access to collection [%d].",
				count));
	}
	public abstract void randomAccess(int count) ;

}
